<template>
  <view class="noticeWarp">
    <view>
      <view class="noticeItem u-border-bottom" v-for="(item,index) in list"
            @click="details(item)"
            :key="index">
        <view class="itemAvatar">
          <img src="https://app.zbzedu.com/static/WaChat/img/logo.png" alt="" v-if="!item.replyUser">
          <img :src="item.replyUser.avatar" alt="" v-else @click="toPersonal(item.replyUser)">
        </view>
        <view class="noticeContent">
          <view class="noticeTitle">
            <text>
              <text class="font-b">{{ item.replyUser.nickName || '' }}</text>
              {{ item.msgDesc }}</text>
          </view>
          <view class="noticeTime">
            <text>{{ $u.timeFrom(item.createTime) }}</text>
          </view>
        </view>
      </view>
      <loadMore :status="status"></loadMore>
    </view>
  </view>
</template>

<script>
  import {request} from "../../util/api"
  import loadMore from '../../components/loadMore'
  import { TOAST } from '../../util/util'
import {getCurrentFullPath} from "../../util/util";
  export default {
    components: {
      loadMore
    },
    data() {
      return {
        userId: '',
        list: [],
        status: 'loading',
        customStyle: {
          background: '#1f476d',
          padding: '0 30rpx'
        }
      };
    },
    created() {
      this.getMessageList()
    },
    methods: {
		// 转发功能
		onShareAppMessage(res) {
		  return {
		    path: getCurrentFullPath()
		  }
		},
      getMessageList() {
        request({
          url: '/system/CompassDiaryMsg/list',
          data: {uId: uni.getStorageSync(process.env.NODE_ENV + 'zbz_user').userId}
        }).then(res => {
          res.rows.forEach(item => {
            item.createTime = new Date(item.createTime.replace(/-/g,'/')).getTime()
          })
          this.list = res.rows
          this.status = 'finished'
        })
      },

      toPersonal(data) {
        this.$u.route({
          url: '/package/forum/personal?id=' + data.userId
        })
      },

      details(item) {
        if (item.linkId) {
          this.$u.route({
            url: '/package/forum/details?id=' + item.linkId
          })
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
.fixed-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  background: #fff;
  .user-btn {
    margin-left: 5%;
    width: 90%;
    margin: 20upx auto;
  }
}

  .noticeWarp {
    .noticeItem {
      display: flex;
      align-items: center;
      padding: 20rpx;

      .itemAvatar {
        margin-right: 20rpx;

        image {
          width: 80rpx;
          height: 80rpx;
          border-radius: 100%;
        }
      }

      .noticeContent {
        .noticeTitle {
          .user {
            font-size: 28rpx;
            font-weight: bold;
          }

          .titleContent {

          }
        }

        .noticeTime {
          font-size: 24rpx;
          color: #C0C0C0;
        }
      }
    }
  }
</style>
